]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
overview: Try to do the right thing related to XDnD
authorJasper St. Pierre <jstpierre@mecheye.net>
Mon, 4 Mar 2013 22:02:02 +0000 (17:02 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Mon, 4 Mar 2013 22:47:47 +0000 (17:47 -0500)
Rather than expose a dizzying array of methods related to managing
state that require infecting every user of the overview methods, try
to do the sensible and smart thing internally. Now, the overview
itself tracks when XDND drags start, and simply calling show, hide or
toggle while an XDnD drag is in effect will show the overview, and
will only take the grab until after the XDND drag ends.

https://bugzilla.gnome.org/show_bug.cgi?id=663661

js/ui/layout.js
js/ui/overview.js
js/ui/panel.js

index 315bc1024ebdb94d74cb5a6918ef662a629e30f0..a697bda5212a5737eef77a6d91b59d802ac3dcb0 100644 (file)
@@ -1221,9 +1221,9 @@ const HotCorner = new Lang.Class({
         if (source != Main.xdndHandler)
             return DND.DragMotionResult.CONTINUE;
 
-        if (!Main.overview.visible && !Main.overview.animationInProgress) {
+        if (Main.overview.shouldToggleByCornerOrButton()) {
             this.rippleAnimation();
-            Main.overview.showTemporarily();
+            Main.overview.toggle();
         }
 
         return DND.DragMotionResult.CONTINUE;
index 35eb020291101d2e11a312324e8248d140a276a5..7d00251d18da2addce510b9355c26769f5ba1d24 100644 (file)
@@ -152,7 +152,6 @@ const Overview = new Lang.Class({
 
         this.visible = false;           // animating to overview, in overview, animating out
         this._shown = false;            // show() and not hide()
-        this._shownTemporarily = false; // showTemporarily() and not hideTemporarily()
         this._modal = false;            // have a modal grab
         this.animationInProgress = false;
         this.visibleTarget = false;
@@ -350,18 +349,22 @@ const Overview = new Lang.Class({
     },
 
     _onDragBegin: function() {
+        this._inXdndDrag = true;
+
         DND.addDragMonitor(this._dragMonitor);
         // Remember the workspace we started from
         this._lastActiveWorkspaceIndex = global.screen.get_active_workspace_index();
     },
 
     _onDragEnd: function(time) {
+        this._inXdndDrag = false;
+
         // In case the drag was canceled while in the overview
         // we have to go back to where we started and hide
         // the overview
-        if (this._shownTemporarily)  {
+        if (this._shown) {
             global.screen.get_workspace_by_index(this._lastActiveWorkspaceIndex).activate(time);
-            this.hideTemporarily();
+            this.hide();
         }
         this._resetWindowSwitchTimeout();
         this._lastHoveredWindow = null;
@@ -409,7 +412,7 @@ const Overview = new Lang.Class({
                                                 this._needsFakePointerEvent = true;
                                                 Main.activateWindow(dragEvent.targetActor._delegate.metaWindow,
                                                                     this._windowSwitchTimestamp);
-                                                this.hideTemporarily();
+                                                this.hide();
                                                 this._lastHoveredWindow = null;
                                             }));
         }
@@ -505,9 +508,10 @@ const Overview = new Lang.Class({
         if (this._shown)
             return;
         this._shown = true;
-        this._syncInputMode();
-        if (!this._modal)
+
+        if (!this._syncInputMode())
             return;
+
         this._animateVisible();
     },
 
@@ -573,24 +577,6 @@ const Overview = new Lang.Class({
         this.emit('showing');
     },
 
-    // showTemporarily:
-    //
-    // Animates the overview visible without grabbing mouse and keyboard input;
-    // if show() has already been called, this has no immediate effect, but
-    // will result in the overview not being hidden until hideTemporarily() is
-    // called.
-    showTemporarily: function() {
-        if (this.isDummy)
-            return;
-
-        if (this._shownTemporarily)
-            return;
-
-        this._syncInputMode();
-        this._animateVisible();
-        this._shownTemporarily = true;
-    },
-
     // hide:
     //
     // Reverses the effect of show()
@@ -604,30 +590,12 @@ const Overview = new Lang.Class({
         if (this._controlPressed)
             return;
 
-        if (!this._shownTemporarily)
-            this._animateNotVisible();
+        this._animateNotVisible();
 
         this._shown = false;
         this._syncInputMode();
     },
 
-    // hideTemporarily:
-    //
-    // Reverses the effect of showTemporarily()
-    hideTemporarily: function() {
-        if (this.isDummy)
-            return;
-
-        if (!this._shownTemporarily)
-            return;
-
-        if (!this._shown)
-            this._animateNotVisible();
-
-        this._shownTemporarily = false;
-        this._syncInputMode();
-    },
-
     toggle: function() {
         if (this.isDummy)
             return;
@@ -659,22 +627,23 @@ const Overview = new Lang.Class({
         // overview we don't have a problem with the release of a press/release
         // going to an application.
         if (this.animationInProgress)
-            return;
+            return true;
 
         if (this._shown) {
-            if (!this._modal) {
-                if (Main.pushModal(this._overview,
-                                   { keybindingMode: Shell.KeyBindingMode.OVERVIEW }))
-                    this._modal = true;
-                else
-                    this.hide();
+            let shouldBeModal = !this._inXdndDrag;
+            if (shouldBeModal) {
+                if (!this._modal) {
+                    if (Main.pushModal(this._overview,
+                                       { keybindingMode: Shell.KeyBindingMode.OVERVIEW })) {
+                        this._modal = true;
+                    } else {
+                        this.hide();
+                        return false;
+                    }
+                }
+            } else {
+                global.stage_input_mode = Shell.StageInputMode.FULLSCREEN;
             }
-        } else if (this._shownTemporarily) {
-            if (this._modal) {
-                Main.popModal(this._overview);
-                this._modal = false;
-            }
-            global.stage_input_mode = Shell.StageInputMode.FULLSCREEN;
         } else {
             if (this._modal) {
                 Main.popModal(this._overview);
@@ -683,6 +652,7 @@ const Overview = new Lang.Class({
             else if (global.stage_input_mode == Shell.StageInputMode.FULLSCREEN)
                 global.stage_input_mode = Shell.StageInputMode.NORMAL;
         }
+        return true;
     },
 
     _animateNotVisible: function() {
@@ -716,7 +686,7 @@ const Overview = new Lang.Class({
 
         this.emit('shown');
         // Handle any calls to hide* while we were showing
-        if (!this._shown && !this._shownTemporarily)
+        if (!this._shown)
             this._animateNotVisible();
 
         this._syncInputMode();
@@ -742,7 +712,7 @@ const Overview = new Lang.Class({
 
         this.emit('hidden');
         // Handle any calls to show* while we were hiding
-        if (this._shown || this._shownTemporarily)
+        if (this._shown)
             this._animateVisible();
 
         this._syncInputMode();
index 2b1ed9b79d938f0941a9d59cf933d176e7b4a2ea..c16e318cd416bec66596b01b9bd17f279398b0c6 100644 (file)
@@ -661,7 +661,7 @@ const ActivitiesButton = new Lang.Class({
         if (this._xdndTimeOut != 0)
             Mainloop.source_remove(this._xdndTimeOut);
         this._xdndTimeOut = Mainloop.timeout_add(BUTTON_DND_ACTIVATION_TIMEOUT,
-                                                 Lang.bind(this, this._xdndShowOverview, actor));
+                                                 Lang.bind(this, this._xdndToggleOverview, actor));
 
         return DND.DragMotionResult.CONTINUE;
     },
@@ -685,15 +685,12 @@ const ActivitiesButton = new Lang.Class({
         }
     },
 
-    _xdndShowOverview: function(actor) {
+    _xdndToggleOverview: function(actor) {
         let [x, y, mask] = global.get_pointer();
         let pickedActor = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, x, y);
 
-        if (pickedActor == this.actor) {
-            if (!Main.overview.visible && !Main.overview.animationInProgress) {
-                Main.overview.showTemporarily();
-            }
-        }
+        if (pickedActor == this.actor && Main.overview.shouldToggleByCornerOrButton())
+            Main.overview.toggle();
 
         Mainloop.source_remove(this._xdndTimeOut);
         this._xdndTimeOut = 0;